package labox.innovation.gameserver.skills.conditions;

import labox.innovation.gameserver.model.L2ItemInstance;
import labox.innovation.gameserver.model.actor.instance.FuzePcInstance;
import labox.innovation.gameserver.model.itemcontainer.Inventory;
import labox.innovation.gameserver.skills.Env;

/**
 * @author mkizub
 * 
 *         TODO To change the template for this generated type comment go to
 *         Window - Preferences - Java - Code Style - Code Templates
 */
public final class ConditionSlotItemId extends ConditionInventory {

	private final int _itemId;
	private final int _enchantLevel;

	public ConditionSlotItemId(int slot, int itemId, int enchantLevel) {
		super(slot);
		_itemId = itemId;
		_enchantLevel = enchantLevel;
	}

	@Override
	public boolean testImpl(Env env) {
		if (!(env.player instanceof FuzePcInstance))
			return false;
		Inventory inv = ((FuzePcInstance) env.player).getInventory();
		L2ItemInstance item = inv.getPaperdollItem(_slot);
		if (item == null)
			return _itemId == 0;
		return item.getItemId() == _itemId && item.getEnchantLevel() >= _enchantLevel;
	}
}
